<template>
    <div class="PopupImplementation">
        <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-model="visible" title=""
            :show-close="false" align-center class="dialogAdd">
            <div class="dialog_content">
                <div class="dialog_header">
                    <div class="title">
                        <img src="@/assets/images/rectangle07.png" alt="">
                        <span>设置执行情况</span>
                    </div>
                </div>
                <div class="dialog_details">
                    <div class="details">
                        <div class="details_item details_item2">
                            <span class="label">工作内容</span>
                            <span class="item_content">汽机排油烟风机出口管底部排污</span>
                        </div>
                        <div class="details_item">
                            <span class="label">执行人</span>
                            <span class="item_content">张三</span>
                        </div>
                        <div class="details_item">
                            <span class="label">负责人</span>
                            <span class="item_content">李四</span>
                        </div>
                        <div class="details_item details_item2">
                            <span class="label">执行状态</span>
                            <span class="item_content item_content2">
                                <el-select v-model="state.data" class="m-2" placeholder="" clearable>
                                    <el-option label="全部" :value="1" />
                                    <el-option label="热控" :value="2" />
                                </el-select>
                                <el-date-picker class="m-3" v-model="receiptTime" type="daterange" range-separator="-"
                                    start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY/MM/DD"
                                    value-format="YYYY-MM-DD" @change="changeReceiptTime" unlink-panels clearable />
                                <el-button type="primary">查询</el-button>
                                <el-button type="primary" @click="implement">执行</el-button>
                                <el-button type="primary" @click="implementCancel">取消执行</el-button>
                                <el-button type="primary" @click="delay">延期</el-button>
                            </span>
                        </div>
                        <div class="table">
                            <el-table ref="tableRef" :data="state.tableData" style="width: 100%;" stripe
                                empty-text='暂无数据' :max-height="300" :scrollbar-always-on="true"
                                @selection-change="handleSelectionChange">
                                <el-table-column type="index" label="序号" width="58" />
                                <el-table-column prop="createName" label="执行状态"/>
                                <el-table-column prop="createName" label="计划开始执行时间"/>
                                <el-table-column prop="createName" label="计划结束执行时间"/>
                                <el-table-column prop="createName" label="执行期限"/>
                            </el-table>
                        </div>
                        <div class="btn">
                            <el-button type="warning" @click="handleClose">确 认</el-button>
                            <el-button @click="handleClose">取 消</el-button>
                        </div>
                    </div>

                </div>
            </div>
        </el-dialog>
        <implementConfirm :dialogVisible="viewimplement" @closeDialog="closeDialogImplement"></implementConfirm>
    </div>
</template>

<script setup lang="ts">
import implementConfirm from './components/implementConfirm.vue'
let viewimplement = ref(false) //执行
let viewimplementCancel = ref(false) //取消执行
let viewdelay = ref(false) //延期

const props = defineProps({
    dialogVisible: {
        type: Boolean,
        default: false
    },
})

let visible = ref(false);

let state = reactive({
    data: '',
    tableData: []
})

watch(() => props.dialogVisible, async (newValue, oldValue) => {
    visible.value = newValue;

});

//emit(父组件中的自定义方法)
const emit = defineEmits(['closeDialog']);

const handleClose = () => {
    emit("closeDialog");
}

const receiptTime = ref("");//接收时间

const changeReceiptTime = (val: string[]) => {
    console.log('val', val);
    if (val && val.length == 2) {
        // advancedSearchData.startTime = val[0] + " 00:00:00";
        // advancedSearchData.endTime = val[1] + " 23:59:59";
    } else {
        // advancedSearchData.startTime = "";
        // advancedSearchData.endTime = "";
    }
}

const handleSelectionChange = (val: any) => {
    let list = [] as Array<string>;
    if (val) {
        val.forEach((item: any) => {
            list.push(item.id);
        })
    }
    // multipleSelection.list = list;
    // state.delData = list
}

// 执行按钮
const implement = () => {
    console.log('@@');
    viewimplement.value = true
}
const closeDialogImplement = () => {
    console.log('@@');
    viewimplement.value = false
}

// 取消执行
const implementCancel = () => {
    console.log('@@');
    viewimplementCancel.value = true

}

// 延期
const delay = () => {
    console.log('@@');
    viewdelay.value = true

}
</script>

<style scoped lang="scss">
.PopupImplementation {
    :deep(.dialogAdd) {
        // width: 400px;
        width: 900px;
        min-height: 500px;
        background: rgba(255, 255, 255, 1);
        border-radius: 2px;
        box-shadow: 0px 6px 16px -8px rgba(0, 0, 0, 0.08), 0px 9px 28px 0px rgba(0, 0, 0, 0.05), 0px 12px 48px 16px rgba(0, 0, 0, 0.03);

        .el-dialog__header {
            padding: 0;

        }

        .el-dialog__body {
            padding: 0;

            .dialog_content {
                .dialog_header {
                    padding: 0;
                    height: 59px;
                    padding: 8px 32px 4px 62px;
                    line-height: 52px;
                    font-size: 16px;
                    font-weight: 400;
                    color: rgba(0, 0, 0, 1);
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    border-bottom: 1px dashed rgba(112, 105, 95, 1);

                    .title {
                        display: flex;
                        align-items: center;

                        img {
                            width: 4px;
                            height: 22px;
                            margin-right: 15px;
                        }

                    }

                    .close {
                        width: 25px;
                        height: 25px;
                        cursor: pointer;

                    }
                }

                .dialog_details {
                    padding: 25px 45px 50px 48px;
                    font-size: 16px;
                    font-weight: 400;
                    letter-spacing: 0px;
                    line-height: 30px;
                    color: rgba(0, 0, 0, 1);

                    .details {

                        padding: 0px 0 0px 0;
                        display: flex;
                        flex-wrap: wrap;

                        .details_item {
                            display: flex;
                            margin-bottom: 10px;
                            width: 50%;

                            &.details_item2 {
                                width: 100%;
                            }

                            .label {
                                width: 80px;
                                text-align: right;
                                display: inline-block;
                                margin-right: 30px;
                                flex-shrink: 0;
                                color: rgb(112, 105, 95);
                            }

                            .item_content {
                                flex: 1;

                                &.item_content2 {
                                    display: flex;
                                    // flex: 0;
                                }

                                .m-2 {
                                    .el-input {
                                        width: 100px;
                                    }

                                }

                                .m-3 {
                                    width: 250px;
                                    margin: 0 10px;
                                }
                            }
                        }

                        .table {
                            width: 100%;
                        }
                        .btn {
                            position: absolute;
                            bottom: 40px;
                            right: 77px;
                        }
                    }

                }

            }
        }


    }
}
</style>